package com.xiaoyi.entity.music;


import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Locale;


public class BaseBean implements Serializable {

    public static final long serialVersionUID = -316172390920775219L;

    @Override
    public String toString() {
        return bean2string(this);
    }


    public static String bean2string(Object obj) {
        String rtn_str = "<========="+ obj.getClass().getSimpleName() +"=========>\n";

        try {
            Class<?> obj_class = obj.getClass();

            Method[] methods = obj_class.getDeclaredMethods();

            for (Method method : methods) {
                String method_name = method.getName();
                if (method_name.startsWith("get") && !method_name.contains("getClass")) {
                    Object method_resul = method.invoke(obj);
                    rtn_str += method_name.substring(3).toLowerCase(Locale.CHINA) + " : " + method_resul + "\n";
                }
            }

            rtn_str += "<========================>\n";
        } catch (Exception e) {
        }

        return rtn_str;
    }
}
